﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.MountAndBlade.View.SimpleSceneTestWithMission
// Assembly: TaleWorlds.MountAndBlade.View, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 61152EB8-513B-4D4A-8AC0-0D1465C6CF6C
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\Modules\Native\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.View.dll

using System.Collections.Generic;
using TaleWorlds.Core;
using TaleWorlds.Engine;
using TaleWorlds.Library;
using TaleWorlds.MountAndBlade.Source.Missions;

#nullable disable
namespace TaleWorlds.MountAndBlade.View
{
  public class SimpleSceneTestWithMission
  {
    private Mission _mission;
    private string _sceneName;
    private DecalAtlasGroup _customDecalGroup;

    public SimpleSceneTestWithMission(string sceneName, DecalAtlasGroup atlasGroup = DecalAtlasGroup.All)
    {
      this._sceneName = sceneName;
      this._customDecalGroup = atlasGroup;
      this._mission = this.OpenSceneWithMission(this._sceneName);
    }

    public bool LoadingFinished()
    {
      return this._mission.IsLoadingFinished && Utilities.GetNumberOfShaderCompilationsInProgress() == 0;
    }

    private Mission OpenSceneWithMission(string scene, string sceneLevels = "")
    {
      LoadingWindow.DisableGlobalLoadingWindow();
      return MissionState.OpenNew(nameof (SimpleSceneTestWithMission), new MissionInitializerRecord(scene)
      {
        PlayingInCampaignMode = false,
        AtmosphereOnCampaign = AtmosphereInfo.GetInvalidAtmosphereInfo(),
        DecalAtlasGroup = (int) this._customDecalGroup,
        SceneLevels = sceneLevels
      }, (InitializeMissionBehaviorsDelegate) (missionController => (IEnumerable<MissionBehavior>) new MissionBehavior[6]
      {
        (MissionBehavior) new MissionOptionsComponent(),
        (MissionBehavior) new BasicLeaveMissionLogic(false, 0),
        (MissionBehavior) new MissionHardBorderPlacer(),
        (MissionBehavior) new MissionBoundaryPlacer(),
        (MissionBehavior) new MissionBoundaryCrossingHandler(),
        (MissionBehavior) new EquipmentControllerLeaveLogic()
      }));
    }
  }
}
